using System.Collections.Generic;
using UnityEngine;

public class Vomit : MonoBehaviour
{
	private ParticleSystem ps;

	public Body body;

	private List<ParticleSystem.Particle> enter = new List<ParticleSystem.Particle>();

	private List<ParticleSystem.Particle> exit = new List<ParticleSystem.Particle>();

	private void OnEnable()
	{
		ps = GetComponent<ParticleSystem>();
	}

	private void OnParticleTrigger()
	{
		if (!body)
		{
			return;
		}
		int triggerParticles = ps.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter);
		for (int i = 0; i < triggerParticles; i++)
		{
			if ((double)Mathf.Abs(body.transform.position.y - body.zombie.player.transform.position.y) <= 0.3 && Random.Range(0f, 1f) > body.zombie.player.body.vomitResistance)
			{
				body.zombie.player.Hurt(4f);
			}
		}
	}
}
